package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Emp;
import com.itheima.pojo.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    Page<Student> list(@Param("name") String name,
                       @Param("no") String no,
                       @Param("degree") Integer degree,
                       @Param("clazzId") Integer clazzId);

    //删除学员
    void delete(@Param("ids") List<Integer> ids);

    //添加学员
    void insert(Student student);

    //根据id查询
    @Select("select * from student where id=#{id}")
    Student findById(Integer id);

    //修改学员
    void updateById(Student student);

    //违纪处理
    @Update("update student set violation_count = violation_count +1 ," +
            " violation_score = violation_score + #{score} , " +
            "update_time = now() " +
            "where id = #{id}")
    void updateViolation(Integer id, Integer score);

    //学员人数统计
    List<Map<String, Object>> getStudentData();
}
